/*******************************************************************************
**
** Copyright (c) 2011 - The OWE Team
**
** This file is part of OWE.
**
** OWE is a free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; version
** version 2.1 of the License.
**
** OWE is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with OWE. If not, see <http://www.gnu.org/licenses/>.
**
*******************************************************************************/

#include <owe/node.h>
#include <owe/paramelement.h>
#include <owe/ustring.h>

OWE_USE_NAMESPACE

/*!
    \class ParamElement
    \brief Custom parameters of features.

    \ingroup Configuration

    Implementation of the feature param element as specified
    <a href="http://www.w3.org/TR/widgets/#param">here</a>.
*/

/*!
    \fn UString ParamElement::name() const

    Returns the parameter <a href="http://www.w3.org/TR/widgets/#name1">name</a>.
    This attribute is mandatory and parameters without name are considered
    invalid.
*/

/*!
    \fn UString ParamElement::value() const

    Returns the parameter <a href="http://www.w3.org/TR/widgets/#value">
    value</a>. This attribute is mandatory and parameters without value are
    considered invalid.
*/

/*!
    Constructs a new ParamElement from a given \a node.
*/
ParamElement::ParamElement(const Node *node)
    : Element(node, Element::Param)
    , m_name(node->attribute("name"))
    , m_value(node->attribute("value"))
{
}

/*!
    Destructs the object releasing all allocated resources.
*/
ParamElement::~ParamElement()
{
}

/*!
    Returns whenever a parameter is considered valid. To be valid, the parameter
    must have both name and value attributes.
*/
bool ParamElement::isValid() const
{
    return (m_name.size() && m_value.size());
}
